<template>
    <div class="default-main ba-table-box">
        <el-alert class="ba-table-alert" v-if="baTable.table.remark" :title="baTable.table.remark" type="info" show-icon />

        <!-- 表格顶部菜单 -->
        <TableHeader
            :buttons="['delete', 'quickSearch']"
            :quick-search-placeholder="t('搜索 账号')"
        />

        <!-- 表格 -->
        <!-- 要使用`el-table`组件原有的属性，直接加在Table标签上即可 -->
        <Table ref="tableRef" />

        <!-- 表单 -->
        <PopupForm />
    </div>
</template>

<script setup lang="ts">
import { ref, provide, markRaw } from 'vue'
import baTableClass from '/@/utils/baTable'
import PopupForm from './popupForm.vue'
import Table from '/@/components/table/index.vue'
import TableHeader from '/@/components/table/header/index.vue'
import { defaultOptButtons } from '/@/components/table'
import { baTableApi } from '/@/api/common'
import { useI18n } from 'vue-i18n'

defineOptions({
    name: 'user/user',
})
import purchase from './render/purchase.vue'

const { t } = useI18n()
const tableRef = ref()
const baTable = new baTableClass(
    new baTableApi('/system/user.User/'),
    {
        column: [
            { type: 'selection', align: 'center', operator: false },

            { // 账号
                label: t('user.user.User name'), 
                prop: 'username', 
                align: 'left', 
                operator: 'LIKE', 
                operatorPlaceholder: t('Fuzzy query'),
            },

            { // 代购费
                label: t('universal.agency_fee'), 
                prop: 'agency_fee', 
                align: 'left', 
                operator: 'LIKE', 
                operatorPlaceholder: t('Fuzzy query'),
                render: 'customRender', 
                customRender: markRaw(purchase),
            },

            // { // 预备金
            //     label: t('预备金'), 
            //     prop: 'agency_fee', 
            //     align: 'left', 
            //     operator: 'LIKE', 
            //     operatorPlaceholder: t('Fuzzy query'),
            //     render: 'customRender', 
            //     customRender: markRaw(renderMoney),
            // },

            { label: t('创建时间'), prop: 'create_time', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
            {
                label: t('Operate'),
                align: 'center',
                width: '100',
                render: 'buttons',
                buttons: defaultOptButtons(['edit', 'delete']),
                operator: false,
            },
        ],
        dblClickNotEditColumn: ['all'],
    },
    {
        defaultItems: {
            
        },
    }
)

baTable.mount()
baTable.getIndex()

provide('baTable', baTable)






</script>

<style scoped lang="scss"></style>
